package com.ccrfid.rmc6.appconfig.app;

import com.ccrfid.rmc6.util.LicenseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;

public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> {
    private static final Logger logger = LoggerFactory.getLogger(ApplicationReadyEventListener.class);

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        int code = LicenseUtil.verifyLicense();
        if (code < 0) {
            logger.error("Application terminated, license err: {}", code);
            System.exit(-1);
        }
        logger.info("Application startup SUCCESS.");
    }
}
